<?php
/*
 * code to generate a new timesheet for a user
*/
session_start();
if(!isset($_SESSION['userid'])){
	header('location:login.php');
}
else
{
	// Create connection
	include("../inc_files/utils/dbconnection.php");

	$stmt = $mysqli->prepare("INSERT INTO timesheets (Timesheet_User, TimesheetPeriod, Deleted, Comments, Status)
			VALUES (?,?,?,?,?);");
	
	//bind the parameters to the statement
	$stmt -> bind_param("ssisi", $userID, $period, $deleted, $comments, $status);
	$userID = $_SESSION["userid"];
	$period = $_POST["period"];
	$deleted = 0;
	$comments = "New timesheet created on ";// + date("d/m/Y"); " \n";
	$status = 1;
	//execute the query
	$result = $stmt -> execute();	
	//tidy up database connection
	$mysqli->close();

}

?>


